using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Model
{
    [Table("WorkOrder")]
    public class WorkOrder
    {
        private int _workOrderId;
        private int _productId;
        private string _workOrderType;
        private string _detailedType;
        private string _workOrderDescription;
        private string _workOrderStatus;
        private DateTime _plannedStartDate;
        private DateTime _plannedDueDate;
        private int _plannedQuantity;
        private int _testProgramNumber;
        private int _companyNumber;

        // 工单 ID（主键）
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int WorkOrderId
        {
            set { _workOrderId = value; }
            get { return _workOrderId; }
        }

        // 产品 ID（外键，非空）
        [Required]
        public int ProductId
        {
            set { _productId = value; }
            get { return _productId; }
        }

        // 工单类型（非空）
        [Required]
        [StringLength(50)]
        public string WorkOrderType
        {
            set { _workOrderType = value; }
            get { return _workOrderType; }
        }

        // 详细类型（可空）
        [StringLength(50)]
        public string DetailedType
        {
            set { _detailedType = value; }
            get { return _detailedType; }
        }

        // 工单说明（可空）
        public string WorkOrderDescription
        {
            set { _workOrderDescription = value; }
            get { return _workOrderDescription; }
        }

        // 工单状态（非空）
        [Required]
        [StringLength(50)]
        public string WorkOrderStatus
        {
            set { _workOrderStatus = value; }
            get { return _workOrderStatus; }
        }

        // 计划开始日期（非空）
        [Required]
        public DateTime PlannedStartDate
        {
            set { _plannedStartDate = value; }
            get { return _plannedStartDate; }
        }

        // 计划到期日（非空）
        [Required]
        public DateTime PlannedDueDate
        {
            set { _plannedDueDate = value; }
            get { return _plannedDueDate; }
        }

        // 计划数量（非空）
        [Required]
        public int PlannedQuantity
        {
            set { _plannedQuantity = value; }
            get { return _plannedQuantity; }
        }

        // 测试程序号（默认 1）
        public int TestProgramNumber
        {
            set { _testProgramNumber = value; }
            get { return _testProgramNumber; }
        }

        // 公司号（默认 1）
        public int CompanyNumber
        {
            set { _companyNumber = value; }
            get { return _companyNumber; }
        }

        public WorkOrder()
        {
            WorkOrderStatus = "已投产";
        }
    }

}